﻿@namespace BootstrapBlazor.Components
@inherits PopoverCompleteBase<string>

@if (IsShowLabel)
{
    <BootstrapLabel required="@Required" for="@InputId" ShowLabelTooltip="ShowLabelTooltip" Value="@DisplayText"/>
}
<div class="@ClassString" id="@Id">
    <input @attributes="AdditionalAttributes" id="@InputId" class="@ClassName" autocomplete="off" type="text"
           data-bs-toggle="@ToggleString" data-bs-placement="@PlacementString"
           data-bs-offset="@OffsetString" data-bs-custom-class="@CustomClassString"
           data-bb-auto-dropdown-focus="@ShowDropdownListOnFocusString" data-bb-debounce="@DurationString"
           data-bb-skip-esc="@SkipEscString" data-bb-skip-enter="@SkipEnterString" data-bb-blur="@TriggerBlurString"
           data-bb-scroll-behavior="@ScrollIntoViewBehaviorString"
           value="@CurrentValueAsString"
           placeholder="@PlaceHolder" disabled="@Disabled" @ref="FocusElement"/>
    <span class="form-select-append"><i class="@Icon"></i></span>
    <span class="form-select-append ac-loading"><i class="@LoadingIcon"></i></span>
    <ul class="dropdown-menu">
        @foreach (var item in Rows)
        {
            <li @key="item" class="dropdown-item" @onclick="() => OnClickItem(item)">
                @if (ItemTemplate == null)
                {
                    <div>@item</div>
                }
                else
                {
                    @ItemTemplate(item)
                }
            </li>
        }
        @if (ShowNoDataTip && Rows.Count == 0)
        {
            <li class="dropdown-item">@NoDataTip</li>
        }
    </ul>
</div>
